﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;

public partial class _Default : System.Web.UI.Page
{
    protected string[] str=new string [5];

    protected void Page_Load(object sender, EventArgs e)
    {
       
        if (!IsPostBack)
        {
           //将BBS表中的数据显示在页面上
            BBS bbs = new BBS();
            int i = 0;
            foreach (var b in bbs.returnLastFiveBBS())
            {
                str[i] = b.content;
                i++;
            }

                //if (Profile.UserName!=null && Roles.GetRolesForUser(Profile.UserName)[0].Equals("Administrator"))
                //{
                //    Response.Redirect("~/Admins/BookManage.aspx");
                //}
           
            //如果是管理员，转入管理界面
            if (Request.Cookies[FormsAuthentication.FormsCookieName]!=null)
           {
                //获取用户身份的代码
                string EncrTicket = Request.Cookies[FormsAuthentication.FormsCookieName].Value;
                 //获得身份验证票  
                 FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(EncrTicket);
                //从身份验证票中提取经过验证的用户名  
                 string UserName = ticket.Name;
                 Admins ads = new Admins();
                 foreach (var ad in ads.GetAllAdmins())
                 {
                     if (ad.managerName == UserName)
                     {
                         Response.Redirect("~/Admins/BookManage.aspx");
                     }
                 }
           }
        }
    }
}
